<?php
namespace app\mxty\model;

use think\Model;
use think\model\concern\SoftDelete;
use app\common\model\UploadFile;

class MemberCard extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $table = 'athlon_membercard';
    protected $pk = 'nid';

    public function image()
    {
        return $this->hasOne(UploadFile::class, 'file_id', 'image_id');
    }

    public function getList()
    {
        return $this->with(['image'])
            ->where('status', 1)
            ->order('sort', 'asc')
            ->select();
    }

    public static function getRecommends()
    {
        return self::with(['image'])->where('status',1)->
        where('recommend',1)->order('sort', 'asc')->select();
    }

    public function getDetail($cardId)
    {
        return $this->with(['image'])->where('status', 1)->find($cardId);
    }
}
